home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / SCRIPT.PAK / BRIEFEX.SPP < prev    next >
Text File  |  1997-05-06  |  4KB  |  194 lines

  1. //----------------------------------------------------------------------------
  2. // cScript
  3. // (C) Copyright 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. // BRIEFEX.SPP
  6. //    Provides support services for BRIEF operations.
  7. //
  8. // $Revision:   1.7  $
  9. //
  10. //----------------------------------------------------------------------------
  11.  
  12. import IDE;
  13. import editor;
  14. import scriptEngine;
  15.  
  16. assign_to_key(declare key, declare function)
  17. {
  18.  if (!initialized(key))
  19.    key = IDE.SimpleDialog("Key to Assign :","<");
  20.  
  21.  if (!initialized(function))
  22.    function = IDE.SimpleDialog("Function to Assign :","");
  23.  
  24.  declare kbd = IDE.KeyboardManager.GetKeyboard("Editor");
  25.  kbd.Assign(key,function,ASSIGN_IMPLICIT_MODIFIER|ASSIGN_IMPLICIT_SHIFT|ASSIGN_IMPLICIT_KEYPAD);
  26. }
  27.  
  28. block_search()
  29. {
  30.  // Togggle case sensitive option.
  31.  editor.SearchOptions.WholeFile = !editor.SearchOptions.WholeFile;
  32.  
  33.  // Notify user.
  34.  if (editor.SearchOptions.WholeFile) {
  35.       IDE.StatusBar = "Block Searching on.";
  36.  } else {
  37.       IDE.StatusBar = "Block Searching off.";
  38.  }
  39. }
  40.  
  41. center()
  42. {
  43.  declare ep = editor.TopView.Position;
  44.  
  45.  ep.Save();
  46.  ep.MoveBOL();
  47.  
  48.  declare String Line(ep.Read());
  49.  Line = Line.Trim(TRUE);
  50.  declare nSpacesNeeded = (editor.Options.BufferOptions.Margin / 2) - (Line.Length / 2);
  51.  
  52.  while (nSpacesNeeded--)
  53.      Line = new String(" " + Line.Text);
  54.  
  55.  editor.DeleteLine();
  56.  ep.InsertText(Line.Text);
  57.  ep.Restore();
  58. }
  59.  
  60. delete_macro()
  61. {
  62.  declare acModule = IDE.SimpleDialog("Macro to delete(unload):");
  63.  if (acModule != "" && scriptEngine.Unload(acModule))
  64.      IDE.StatusBar = acModule + " unloaded.";
  65.  else
  66.      IDE.StatusBar = "delete_macro : " + acModule + " macro isn't loaded.";
  67. }
  68.  
  69. load_macro()
  70. {
  71.  declare acModule = IDE.SimpleDialog("Macro to load:");
  72.  if (acModule != "" && scriptEngine.Load(acModule))
  73.      IDE.StatusBar = acModule + " loaded.";
  74.  else
  75.      IDE.StatusBar = "Unable to load macro file : " + acModule;
  76. }
  77.  
  78. unload_macro()
  79. {
  80.  declare acModule = IDE.SimpleDialog("Macro to delete:");
  81.  if (acModule != "" && scriptEngine.Unload(acModule))
  82.      IDE.StatusBar = acModule + " deleted.";
  83.  else
  84.      IDE.StatusBar = "Unable to delete macro file : " + acModule;
  85. }
  86.  
  87. next_char(declare nAmount)
  88. {
  89.  declare ep = editor.TopView.Position;
  90.  declare nR = ep.Row;
  91.  declare nC = ep.Column;
  92.  
  93.  if (!initialized(nAmount))
  94.     nAmount = 1;
  95.  
  96.  while (nAmount--) {
  97.     if (ep.Character == 13) {
  98.        editor.ModalMoveRelative(1,0);
  99.        editor.ModalMoveBOL();
  100.     } else {
  101.        editor.ModalMoveRelative(0,1);
  102.     }
  103.  }
  104.  
  105.  if (ep.Row != nR || ep.Column != nC)
  106.    return TRUE;
  107.  else
  108.    return FALSE;
  109. }
  110.  
  111. prev_char(declare nAmount)
  112. {
  113.  declare ep = editor.TopView.Position;
  114.  declare nR = ep.Row;
  115.  declare nC = ep.Column;
  116.  
  117.  if (!initialized(nAmount))
  118.     nAmount = 1;
  119.  
  120.  while(nAmount--) {
  121.     if (ep.Column == 1) {
  122.        editor.ModalMoveRelative(-1,0);
  123.        editor.ModalMoveEOL();
  124.     } else {
  125.        editor.ModalMoveRelative(0,-1);
  126.     }
  127.  }
  128.  
  129.  if (ep.Row != nR || ep.Column != nC)
  130.     return TRUE;
  131.  else
  132.     return FALSE;
  133. }
  134.  
  135. reform()
  136. {
  137.  
  138. }
  139.  
  140. tolower()
  141. {
  142.  declare eb = editor.BlockExists();
  143.  if (eb) { // Do the block only.
  144.     eb.LowerCase();
  145.  } else { // Do the entire line.
  146.     declare ep = editor.TopView.Position;
  147.     ep.Save();
  148.     ep.MoveBOL();
  149.     declare String sLine(ep.Read());
  150.     sLine = sLine.Lower();
  151.     editor.DeleteLine();
  152.     ep.InsertText(sLine.Text);
  153.     ep.Restore();
  154.  }
  155. }
  156.  
  157. toupper()
  158. {
  159.  declare eb = editor.BlockExists();
  160.  if (eb) { // Do the block only.
  161.     eb.UpperCase();
  162.  } else { // Do the entire line.
  163.     declare ep = editor.TopView.Position;
  164.     ep.Save();
  165.     ep.MoveBOL();
  166.     declare String sLine(ep.Read());
  167.     sLine = sLine.Upper();
  168.     editor.DeleteLine();
  169.     ep.InsertText(sLine.Text);
  170.     ep.Restore();
  171.  }
  172. }
  173.  
  174. i_search() {
  175.  editor.IncrementalSearch();
  176. }
  177.  
  178. swap_anchor() {
  179.  
  180.  declare eb = editor.BlockExists();
  181.  
  182.  if (eb != NULL) {
  183.     
  184.     declare ep = editor.TopView.Position;
  185.  
  186.     if (ep.Row == eb.EndingRow && ep.Column == eb.EndingColumn)
  187.        editor.MoveCursorToMarkBegin();
  188.     else
  189.        editor.MoveCursorToMarkEnd();  
  190.  }
  191. }
  192.  
  193.  
  194.